package com.yx.changdao.common.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.yx.changdao.common.annotation.AutoFill;
import com.yx.changdao.common.valid.Default;
import com.yx.changdao.common.valid.Update;
import com.yx.changdao.common.utils.SysUtils;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

@Getter
@Setter
@TableName(Worker.TABLE_NAME)
public class Worker implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 数据库名
     */
    public static final String TABLE_NAME = "worker";

    /**
     * 人员id
     */
    public static final String ID = "id";
    /**
     * 部门id
     */
    public static final String DEP_ID = "dep_id";
    /**
     * 账户id
     */
    public static final String SYS_USER_ID = "sys_user_id";
    /**
     * 姓名
     */
    public static final String NAME = "name";
    /**
     * 身份证
     */
    public static final String ID_CARD = "id_card";
    /**
     * 工作单位
     */
    public static final String OFFICE_NAME = "office_name";
    /**
     * 职务级别
     */
    public static final String OFFICE_LEVEL = "office_level";
    /**
     * 手机号
     */
    public static final String PHONE = "phone";
    /**
     * 性别(1:男 0:女)
     */
    public static final String GENDER = "gender";
    /**
     * 籍贯
     */
    public static final String HOMETOWN = "hometown";
    /**
     * 政治面貌
     */
    public static final String POLITICAL = "political";
    /**
     * 微信
     */
    public static final String WECHAT = "wechat";
    /**
     * 邮箱
     */
    public static final String EMAIL = "email";
    /**
     * 学历
     */
    public static final String EDUCATION = "education";
    /**
     * 创建时间
     */
    public static final String CREATE_TIME = "create_time";
    /**
     * 创建人
     */
    public static final String CREATE_BY_NAME = "create_by_name";
    /**
     * 创建人id
     */
    public static final String CREATE_BY = "create_by";
    /**
     * 更新时间
     */
    public static final String UPDATE_TIME = "update_time";
    /**
     * 更新人
     */
    public static final String UPDATE_BY_NAME = "update_by_name";
    /**
     * 更新人id
     */
    public static final String UPDATE_BY = "update_by";

    /**
     * 人员id
     */
    @TableId(type = IdType.AUTO)
    @NotNull(message = "人员id不能为空",groups = Update.class)
    private Integer id;
    /**
     * 部门id
     */
    @NotNull(message = "部门id不能为空",groups = {Update.class, Default.class})
    private Integer depId;
    /**
     * 账户id
     */
    private String sysUserId;
    /**
     * 姓名
     */
    @NotEmpty(message = "员工姓名不能为空",groups = {Update.class, Default.class})
    private String name;
    /**
     * 身份证
     */
    private String idCard;
    /**
     * 工作单位
     */

    private String officeName;
    /**
     * 职务级别
     */

    private String officeLevel;
    /**
     * 手机号
     */
    @NotEmpty(message = "手机号不能为空",groups = {Update.class, Default.class})
    @Length(message = "11位手机号码",min = 11,max = 11,groups = {Update.class, Default.class})
    private String phone;
    /**
     * 性别(1:男 0:女)
     */
    @NotNull(message = "性别不能为空",groups = {Update.class, Default.class})
    @Range(min = 0,max = 1,message = "只能0或1",groups = {Update.class, Default.class})
    private Integer gender;
    /**
     * 籍贯
     */
    private String hometown;
    /**
     * 政治面貌
     */
    private String political;
    /**
     * 微信
     */
    private String wechat;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 学历
     */
    private String education;
    /**
     * 创建时间
     */
    @AutoFill
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;
    /**
     * 创建人
     */
    @AutoFill(klass= SysUtils.class,method = "currentUserName")
    @TableField(fill = FieldFill.INSERT)
    private String createByName;
    /**
     * 创建人id
     */
    @AutoFill(klass= SysUtils.class,method = "currentUserId")
    @TableField(fill = FieldFill.INSERT)
    private String createBy;
    /**
     * 更新时间
     */
    @AutoFill
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;
    /**
     * 更新人
     */
    @AutoFill(klass= SysUtils.class,method = "currentUserName")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateByName;
    /**
     * 更新人id
     */
    @AutoFill(klass= SysUtils.class,method = "currentUserId")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

}
